package com.woniuxy.oa.web;

import com.woniuxy.oa.entity.Application;
import com.woniuxy.oa.entity.Emp;
import com.woniuxy.oa.entity.ResponseVO;
import com.woniuxy.oa.service.ApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mr X
 */
@CrossOrigin
@RestController
@RequestMapping("application")
public class ApplicationController {
    @Autowired
    private ApplicationService applicationService;

    @PostMapping("add")
    public void add(@RequestBody Application application) throws Exception {
        Emp emp = new Emp();
        emp.setId(application.getEmpId());
        application.setEmp(emp);
        System.out.println(application);
        applicationService.add(application);
    }

    @PostMapping("list")
    public ResponseVO list(@RequestBody Application application) {
        return new ResponseVO("200", "查询成功", applicationService.getById(application.getEmpId()));
    }

    @PostMapping("business")
    public ResponseVO business(@RequestBody Application application) {
        return new ResponseVO("200", "查询成功", applicationService.getBusiness(application.getEmpId()));
    }
}
